var _util = require('util/util.js');

var _catalog_service = {
    getProductList : function(categoryId,resolve,reject){
        _util.request({
            url     : _util.getServerURL("catalog/categories/" + categoryId + "/products"),
            //method 默认get
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    getItemList : function(productId,resolve,reject){
        _util.request({
            url     : _util.getServerURL("catalog/products/" + productId + "/items"),
            //method 默认get
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
    getItemVOById : function(itemId,resolve, reject){
        _util.request({
            url     : _util.getServerURL('catalog/itemVOs/' + itemId),
            method  : 'GET',
            success : resolve,
            error   : reject
        });
    },
    addToCart : function(itemId,resolve,reject){
        _util.request({
            url     : _util.getServerURL('cart/cartItems/'+itemId),
            method  : 'PUT',
            success : resolve,
            error   : reject
        });
    },

    SearchProductList : function(productId,resolve,reject){
        _util.request({
            url     : _util.getServerURL("catalog/likedProduct/" + productId),
            method  : 'GET',
            success : resolve,
            error   : reject,
        });
    },
}

module.exports = _catalog_service;